<!--  -->
<template>
  <div class="Backforth">
    <!-- 重新搜索 -->
    <div>
      <el-form :inline="true" :model="GoSearchWhere" class="demo-form-inline">
        <el-form-item label="">
          <el-select
            clearable
            :default-first-option="true"
            v-model="GoSearchWhere.OrgAirport"
            filterable
            placeholder="请选择"
          >
            <el-option
              v-for="(item, index) in restaurants"
              :key="index"
              :label="item.airportCityName + '-' + item.airportId"
              :value="item.airportId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="">
          <el-select
            clearable
            :default-first-option="true"
            v-model="GoSearchWhere.DstAirport"
            filterable
            placeholder="请选择"
          >
            <el-option
              v-for="(item, index) in restaurants"
              :key="index"
              :label="item.airportCityName + '-' + item.airportId"
              :value="item.airportId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="">
          <el-date-picker
            :picker-options="pickerOptions"
            v-model="GoSearchWhere.DepDate"
            type="date"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="">
          <el-date-picker
            :picker-options="pickerOptions"
            v-model="GoSearchWhere.ArrivedDate"
            type="date"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="">
          <el-button type="primary" @click="Searchagain">重新搜索</el-button>
          <el-button @click="clearCache()">清空缓存</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 数据 -->
    <div style="display: flex; justify-content: space-between">
      <!-- 去程数据 -->
      <div class="boxa">
        <el-tabs v-model="resource" @tab-click="filtrates" style="width: 265px">
          <el-tab-pane label="起飞时间从早到晚" name="runtime"></el-tab-pane>
          <el-tab-pane label="舱位价格从低到高" name="departtime"></el-tab-pane>
        </el-tabs>
        <!-- GoSearch-->
        <div
          v-for="(item, index) in GoSearchWhereList"
          :key="index"
          :class="active == index ? 'GoSearch1' : 'GoSearch'"
        >
          <div style="margin: 0 20px 0 0">
            <img :src="item.airlineGif" alt="" />
          </div>
          <div>
            <!-- 上方 -->
            <div style="display: flex">
              <div>
                <span style="font-size: 12px">{{ item.airline }}</span
                >:
                <span style="font-size: 12px">{{ item.flightNo }}</span>
              </div>
              <div style="margin: 0 0 0 20px">
                <span style="font-size: 12px; font-weight: bold">{{
                  item.depDate
                }}</span>
              </div>
              <div style="margin: 0 0 0 20px">
                <img
                  style="width: 100px"
                  src="../../assets/aircraft50.png"
                  alt=""
                />
              </div>
              <div style="margin: 0 0 0 20px; font-weight: bold">
                <span style="font-size: 12px">{{ item.arrDate }} <span style="color:red"> {{item.arrad? '(+'+item.arrad+'天)':''}}</span> </span>
              </div>
            </div>
            <!-- 上方 -->
            <div style="display: flex">
              <div>
                <span style="font-size: 12px"
                  >机型：{{
                    item.planeTypeDesc == null
                      ? "无机型数据"
                      : item.planeTypeDesc
                  }}</span
                >
              </div>
              <div style="margin: 0 0 0 20px">
                <span style="font-size: 12px">{{ item.orgAirportName+(item.depTerm?item.depTerm:'')}}</span>
              </div>
              <div style="margin: 0 0 0 90px">
                <span style="font-size: 12px">{{ item.flightTimes }}</span>
              </div>
              <div style="margin: 0 0 0 80px">
                <span style="font-size: 12px">{{ item.dstAirportName+(item.arrTerm?item.arrTerm:'') }}</span>
              </div>
            </div>
          </div>
          <div style="margin: 5px 0 0 20px">
            <span style="font-size: 14px"
              >餐食：{{ item.meal == null ? "无" : item.meal }}</span
            >
          </div>
          <div style="margin: 0 0 0 20px">
            <el-tooltip placement="bottom" effect="light">
              <div slot="content">
                票价：<span style="color: red">{{
                  item.listCabinInfo[0].price
                }}</span
                ><br />
                机建： <span style="color: red">{{ item.airportTax }}</span
                ><br />
                燃油：<span style="color: red">{{ item.fuelTax }}</span
                ><br />
                   儿童价：<span style="color: red">{{ item.listCabinInfo[0].chdPrice }}</span
              ><br />
                婴儿价：<span style="color: red">{{ item.listCabinInfo[0].infPrice }}</span
              ><br />
              </div>
              <span style="font-size: 18px; color: #3871db; font-weight: bold"
                >{{
                  item.listCabinInfo[0].price + item.airportTax + item.fuelTax
                }}起(含税)</span
              >
            </el-tooltip>
          </div>
          <div style="margin: 0 0 0 20px">
            <el-button
              v-if="item.nearFlight == false"
              size="mini"
              type="primary"
              @click="GoSearchClick(index, item)"
              >选择</el-button
            >
            <el-button v-if="item.nearFlight == true" type="info" plain disabled
              >选择</el-button
            >
          </div>
        </div>
      </div>
      <!-- 返程数据 -->
      <div v-if="BackSearchList.length != 0" class="boxa">
        <el-tabs
          v-model="resourceasas"
          @tab-click="filtratesasas"
          style="width: 265px"
        >
          <el-tab-pane label="起飞时间从早到晚" name="runtime"></el-tab-pane>
          <el-tab-pane label="舱位价格从低到高" name="departtime"></el-tab-pane>
        </el-tabs>
        <div
          v-for="(item, index) in BackSearchList"
          :key="index"
          :class="active1 == index ? 'GoSearch1' : 'GoSearch'"
        >
          <div style="margin: 0 20px 0 0">
            <img :src="item.airlineGif" alt="" />
          </div>
          <div>
            <!-- 上方 -->
            <div style="display: flex">
              <div>
                <span style="font-size: 12px">{{ item.airline }}</span
                >:
                <span style="font-size: 12px">{{ item.flightNo }}</span>
              </div>
              <div style="margin: 0 0 0 20px">
                <span style="font-size: 12px; font-weight: bold">{{
                  item.depDate
                }}</span>
              </div>
              <div style="margin: 0 0 0 20px">
                <img
                  style="width: 100px"
                  src="../../assets/aircraft50.png"
                  alt=""
                />
              </div>
              <div style="margin: 0 0 0 20px; font-weight: bold">
                <span style="font-size: 12px">{{ item.arrDate }} <span style="color:red"> {{item.arrad? '(+'+item.arrad+'天)':''}}</span></span>
              </div>
            </div>
            <!-- 上方 -->
            <div style="display: flex">
              <div>
                <span style="font-size: 12px"
                  >机型：{{
                    item.planeTypeDesc == null
                      ? "无机型数据"
                      : item.planeTypeDesc
                  }}</span
                >
              </div>
              <div style="margin: 0 0 0 20px">
                <span style="font-size: 12px">{{ item.orgAirportName+(item.depTerm?item.depTerm:'') }}</span>
              </div>
              <div style="margin: 0 0 0 90px">
                <span style="font-size: 12px">{{ item.flightTimes }}</span>
              </div>
              <div style="margin: 0 0 0 80px">
                <span style="font-size: 12px">{{ item.dstAirportName+(item.arrTerm?item.arrTerm:'')  }}</span>
              </div>
            </div>
          </div>
          <div style="margin: 5px 0 0 20px">
            <span style="font-size: 14px"
              >餐食：{{ item.meal == null ? "无" : item.meal }}</span
            >
          </div>
          <div style="margin: 0 0 0 20px">
            <el-tooltip placement="bottom" effect="light">
              <div slot="content">
                票价：<span style="color: red">{{
                  item.listCabinInfo[0].price
                }}</span
                ><br />
                机建： <span style="color: red">{{ item.airportTax }}</span
                ><br />
                燃油：<span style="color: red">{{ item.fuelTax }}</span
                ><br />
                 儿童价：<span style="color: red">{{ item.listCabinInfo[0].chdPrice }}</span
              ><br />
                婴儿价：<span style="color: red">{{ item.listCabinInfo[0].infPrice }}</span
              ><br />
              </div>
              <span style="font-size: 18px; color: #3871db; font-weight: bold"
                >{{
                  item.listCabinInfo[item.listCabinInfo.length - 1].price +
                  item.airportTax +
                  item.fuelTax
                }}起(含税)</span
              >
            </el-tooltip>
          </div>
          <div style="margin: 0 0 0 20px">
            <el-button
              v-if="item.nearFlight == false"
              size="mini"
              type="primary"
              @click="BackSearchClick(index, item)"
              >选择</el-button
            >
            <el-button v-if="item.nearFlight == true" type="info" plain disabled
              >选择</el-button
            >
          </div>
          <!-- <hr/> -->
        </div>
      </div>
    </div>
    <!-- 选择舱位 -->
    <div
      style="
        display: flex;
        justify-content: space-between;
        margin: 40px 0 0 0;
        font-size: 14px;
      "
      v-if="goshippingspace.length > 0 && this.Backshippingspace.length > 0"
    >
      <!-- 去程 -->
      <div class="boxcc">
        <div
          style="display: flex; margin: 0 0 20px 0"
          v-for="(item, index) in goshippingspace"
          :key="index"
          :class="active3 == index ? 'GoSearch1' : 'GoSearch'"
        >
          <div>{{ fightGoNum.airline }}</div>
          <div style="margin: 0 0 0 20px">
            {{ item.cabin }}舱;{{ item.baseCabinName }}
          </div>
          <div style="margin: 0 0 0 20px">
            行李额：{{ item.baggage == null ? "暂无" : item.baggage }}
          </div>
          <el-tooltip
            style="margin: 0 0 0 20px"
            placement="bottom"
            effect="light"
          >
            <div slot="content">
              <span>行李额: {{ item.baggage == null ? "暂无" : item.baggage}}</span><br />
              <span>改签规则：</span><br />
              <div v-for="(item, index) in item.changeRules" :key="index">
                <div style="display: flex; justify-content: space-between">
                  <div>{{ item.time }}</div>
                  <div style="margin: 0 0 0 40px">{{ item.changeRules }}</div>
                </div>
              </div>
              <br />
              <span>退票规则：</span><br />
              <div v-for="(item, index) in item.refundChangeRules" :key="index">
                <div style="display: flex; justify-content: space-between">
                  <div>{{ item.time }}</div>
                  <div style="margin: 0 0 0 40px">{{ item.refundRules }}</div>
                </div>
              </div>
              <br />
            </div>
            <span>退改签规则</span>
          </el-tooltip>
          <div style="margin: 0 0 0 20px">
            {{
              item.cabinLeftDesc == "座位充足"
                ? item.cabinLeftDesc
                : "剩余：" + item.cabinLeftDesc + "张"
            }}
          </div>
          <!-- <div >(含税)</div> -->
          <el-tooltip placement="bottom" effect="light">
            <div slot="content">
              票价：<span style="color: red">{{ item.price }}</span
              ><br />
              机建： <span style="color: red">{{ fightGoNum.airportTax }}</span
              ><br />
              燃油：<span style="color: red">{{ fightGoNum.fuelTax }}</span
              ><br />
              儿童价：<span style="color: red">{{ item.chdPrice }}</span
              ><br />
                婴儿价：<span style="color: red">{{ item.infPrice }}</span
              ><br />
            </div>
            <span
              style="
                font-size: 15px;
                color: #3871db;
                font-weight: bold;
                margin: 0 0 0 20px;
              "
              >{{
                item.price + fightGoNum.airportTax + fightGoNum.fuelTax
              }}(含税)</span
            >
          </el-tooltip>
          <div style="margin: 0 0 0 20px">
            <el-button
              size="mini"
              type="primary"
              @click="gocangwei(index, item)"
              >选择</el-button
            >
          </div>
        </div>
      </div>
      <!-- 返程 -->
      <div class="boxcc">
        <!--  class="boxads" -->
        <div
          style="display: flex; margin: 0 0 20px 0"
          v-for="(item, index) in Backshippingspace"
          :key="index"
          :class="active4 == index ? 'GoSearch1' : 'GoSearch'"
        >
          <div>{{ fightGoNum.airline }}</div>
          <div style="margin: 0 0 0 20px">
            {{ item.cabin }}舱;{{ item.baseCabinName }}
          </div>
          <div style="margin: 0 0 0 20px">
            行李额：{{ item.baggage == null ? "暂无" : item.baggage }}
          </div>
          <el-tooltip
            style="margin: 0 0 0 20px"
            placement="bottom"
            effect="light"
          >
            <div slot="content">
              <span>行李额: {{ item.baggage == null ? "暂无" : item.baggage}}</span><br />
              <span>改签规则：</span><br />
              <div v-for="(item, index) in item.changeRules" :key="index">
                <div style="display: flex; justify-content: space-between">
                  <div>{{ item.time }}</div>
                  <div style="margin: 0 0 0 40px">{{ item.changeRules }}</div>
                </div>
              </div>
              <br />
              <span>退票规则：</span><br />
              <div v-for="(item, index) in item.refundChangeRules" :key="index">
                <div style="display: flex; justify-content: space-between">
                  <div>{{ item.time }}</div>
                  <div style="margin: 0 0 0 40px">{{ item.refundRules }}</div>
                </div>
              </div>
              <br />
            </div>
            <span>退改签规则</span>
          </el-tooltip>
          <div style="margin: 0 0 0 20px">{{ item.cabinLeftDesc }}</div>
          <el-tooltip placement="bottom" effect="light">
            <div slot="content">
              票价：<span style="color: red">{{ item.price }}</span
              ><br />
              机建： <span style="color: red">{{ fightGoNum.airportTax }}</span
              ><br />
              燃油：<span style="color: red">{{ fightGoNum.fuelTax }}</span
              ><br />
                 儿童价：<span style="color: red">{{ item.chdPrice }}</span
              ><br />
                婴儿价：<span style="color: red">{{ item.infPrice }}</span
              ><br />
            </div>
            <span
              style="
                font-size: 15px;
                color: #3871db;
                font-weight: bold;
                margin: 0 0 0 20px;
              "
              >{{
                item.price + fightGoNum.airportTax + fightGoNum.fuelTax
              }}(含税)</span
            >
          </el-tooltip>
          <div style="margin: 0 0 0 20px">
            <el-button
              size="mini"
              type="primary"
              @click="fancangwei(index, item)"
              >选择</el-button
            >
          </div>
        </div>
      </div>
    </div>
    <!-- 最低价舱位 -->
    <div
      style="
        margin: 20px 0 0 15%;
        display: flex;
        justify-content: space-between;
        width: 750px;
      "
      v-if="fightGoList.price && fightBackList.price"
    >
      <div>
        <!-- 去程信息 -->
        <div style="font-size: 14px; display: flex">
          <span>去程：{{ fightGoNum.airline }}</span>
          <span style="margin: 0 0 0 20px"
            >{{ fightGoList.cabin }}舱;{{ fightGoList.baseCabinName }}</span
          >
          <span style="margin: 0 0 0 20px"
            >行李额：{{
              fightGoList.baggage == null ? "暂无" : fightGoList.baggage
            }}</span
          >
          <el-tooltip
            style="margin: 0 0 0 20px"
            placement="bottom"
            effect="light"
          >
            <div slot="content">
              <span>行李额: {{ fightGoList.baggage == null ? "暂无" : fightGoList.baggage}}</span><br />
              <span>改签规则：</span><br />
              <div
                v-for="(item, index) in fightGoList.changeRules"
                :key="index"
              >
                <div style="display: flex; justify-content: space-between">
                  <div>{{ item.time }}</div>
                  <div style="margin: 0 0 0 40px">{{ item.changeRules }}</div>
                </div>
              </div>
              <br />
              <span>退票规则：</span><br />
              <div
                v-for="(item, index) in fightGoList.refundChangeRules"
                :key="index"
              >
                <div style="display: flex; justify-content: space-between">
                  <div>{{ item.time }}</div>
                  <div style="margin: 0 0 0 40px">{{ item.refundRules }}</div>
                </div>
              </div>
              <br />
            </div>
            <span>退改签规则</span>
          </el-tooltip>
          <!-- <span></span> -->
          <div style="margin: 0 0 0 20px">
            <el-tooltip placement="bottom" effect="light">
              <div slot="content">
                票价：<span style="color: red">{{ fightGoList.price }}</span
                ><br />
                机建：
                <span style="color: red">{{ fightGoNum.airportTax }}</span
                ><br />
                燃油：<span style="color: red">{{ fightGoNum.fuelTax }}</span
                ><br />
                儿童：
                <span style="color: red">{{ fightGoNum.listCabinInfo[0].chdPrice }}</span
                ><br />
                婴儿：<span style="color: red">{{ fightGoNum.listCabinInfo[0].infPrice }}</span
                ><br />
              </div>
              <span style="font-size: 15px; color: #3871db; font-weight: bold"
                >{{
                  fightGoList.price +
                  fightGoNum.airportTax +
                  fightGoNum.fuelTax
                }}(含税)</span
              >
            </el-tooltip>
          </div>
        </div>
        <!-- 返程 -->
        <div style="font-size: 14px; display: flex">
          <span>返程：{{ fightBackNum.airline }}</span>
          <span style="margin: 0 0 0 20px"
            >{{ fightBackList.cabin }}舱;{{
              fightBackList.baseCabinName
            }}</span
          >
          <span style="margin: 0 0 0 20px"
            >行李额：{{
              fightBackList.baggage == null ? "暂无" : fightBackList.baggage
            }}</span
          >
          <el-tooltip
            style="margin: 0 0 0 20px"
            placement="bottom"
            effect="light"
          >
            <div slot="content">
              <span>行李额: {{ fightBackList.baggage == null ? "暂无" : fightBackList.baggage}}</span><br />
              <span>改签规则：</span><br />
              <div
                v-for="(item, index) in fightBackList.changeRules"
                :key="index"
              >
                <div style="display: flex; justify-content: space-between">
                  <div>{{ item.time }}</div>
                  <div style="margin: 0 0 0 40px">{{ item.changeRules }}</div>
                </div>
              </div>
              <br />
              <span>退票规则：</span><br />
              <div
                v-for="(item, index) in fightBackList.refundChangeRules"
                :key="index"
              >
                <div style="display: flex; justify-content: space-between">
                  <div>{{ item.time }}</div>
                  <div style="margin: 0 0 0 40px">{{ item.refundRules }}</div>
                </div>
              </div>
              <br />
            </div>
            <span>退改签规则</span>
          </el-tooltip>
          <!-- <span></span> -->
          <div style="margin: 0 0 0 20px">
            <el-tooltip placement="bottom" effect="light">
              <div slot="content">
                票价：<span style="color: red">{{ fightBackList.price }}</span
                ><br />
                机建：
                <span style="color: red">{{ fightBackNum.airportTax }}</span
                ><br />
                燃油：<span style="color: red">{{ fightBackNum.fuelTax }}</span
                ><br />
                儿童：
                <span style="color: red">{{ fightBackNum.listCabinInfo[0].chdPrice }}</span
                ><br />
                婴儿：<span style="color: red">{{ fightBackNum.listCabinInfo[0].infPrice }}</span
                ><br />
              </div>
              <span style="font-size: 15px; color: #3871db; font-weight: bold"
                >{{
                  fightBackList.price +
                  fightBackNum.airportTax +
                  fightBackNum.fuelTax
                }}(含税)</span
              >
            </el-tooltip>
          </div>
        </div>
      </div>
      <div style="display: flex">
        <div
          style="
            font-size: 20px;
            font-weight: bold;
            margin: 5px 0 0 0;
            color: red;
          "
        >
          <el-tooltip placement="bottom" effect="light">
            <div slot="content">
              <span>去程票价：{{ fightGoList.price }}</span
              ><br />
              <span>去程机建：{{ fightGoNum.airportTax }}</span
              ><br />
              <span>去程燃油：{{ fightGoNum.fuelTax }}</span
              ><br />
              <span>返程票价：{{ fightBackList.price }}</span
              ><br />
              <span>返程机建：{{ fightBackNum.airportTax }}</span
              ><br />
              <span>返程燃油：{{ fightBackNum.fuelTax }}</span
              ><br />
              <span
                >总票价：{{
                  fightGoList.price +
                  fightGoNum.airportTax +
                  fightGoNum.fuelTax +
                  fightBackList.price +
                  fightBackNum.airportTax +
                  fightBackNum.fuelTax
                }}</span
              >
            </div>
            <span
              >总价：{{
                fightGoList.price +
                fightGoNum.airportTax +
                fightGoNum.fuelTax +
                fightBackList.price +
                fightBackNum.airportTax +
                fightBackNum.fuelTax
              }}(含税)</span
            >
          </el-tooltip>
        </div>
        <div style="margin: 0 0 0 20px">
          <el-button type="primary" @click="flightdetails">预定</el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "Backforth",
  data() {
    return {
      children: false,
      hasBaby: false,
      // 去程所有舱位
      goshippingspace: [],
      // 往返所有舱位
      Backshippingspace: [],
      // 去程当前航班信息
      fightGoNum: {},
      fightGoList: {},
      // 返程当前航班信息
      fightBackList: {},
      fightBackNum: {},
      // 返程信息
      BackSearchList: [],
      filteractive: "departtime",
      filteractiveasas: "",
      // 默认事件排序
      resource: "",
      resourceasas: "",
      active: -1,
      active1: -1,
      active3: -1,
      active4: -1,
      // 去程信息
      GoSearchWhereList: [],
      // 城市
      restaurants: [],
      // 重新搜索表单
      formInline: {},
      GoSearchWhere: {
        DstAirport: "",
        OrgAirport: "",
        DepDate: "",
        ArrivedDate: "",
      },
      BackSearchWhere: {},
      // 时间选择器
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;
        },
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            },
          },
          {
            text: "明天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() + 3600 * 1000 * 24);
              picker.$emit("pick", date);
            },
          },
          {
            text: "后天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() + 3600 * 1000 * 24 * 2);
              picker.$emit("pick", date);
            },
          },
        ],
      },
    };
  },
  components: {},
  //方法集合
  methods: {
    // 往返选中的舱位
    fancangwei(row, index) {
      this.active4 = row;
      console.log(row, index);
      this.fightBackList = index;
    },
    // 去程选择的舱位
    gocangwei(row, index) {
      this.active3 = row;
      console.log(row, index);
      this.fightGoList = index;
    },
    clearCache() {
      // let list = this.GoSearchWhere;
      this.$axios
        .clearFlightCache({
          depDate: this.GoSearchWhere.DepDate,
          dstAirport: this.GoSearchWhere.DstAirport,
          orgAirport: this.GoSearchWhere.OrgAirport,
          backDepDate: this.GoSearchWhere.ArrivedDate,
        })
        .then((res) => {
          console.log(res);
          if (res.code == 200) {
            this.$message({
              message: res.msg,
              type: "success",
            });
          } else {
          }
        });
    },
    // // 预定按钮
    flightdetails() {
      let b = this.fightGoNum.depDate.indexOf(" ");
      var f = this.fightGoNum.depDate.substring(0, b);
      console.log(f);
      let a = this.fightBackNum.depDate.indexOf(" ");
      var e = this.fightBackNum.depDate.substring(0, a);
      console.log(e);
      // 去程信息
      let GoSearchWhere = {
        CabinMessage:this.fightGoList,
        active: this.active3,
        DepDate: f,
        DstAirport: this.GoSearchWhere.DstAirport,
        FlightNo: this.fightGoNum.flightNo,
        OrgAirport: this.GoSearchWhere.OrgAirport,
        channelType: this.fightGoNum.channelType,
        // index: index,
        cabin: this.fightGoList.cabin,
        baseCabin: this.fightGoList.baseCabin,
        baseCabinName: this.fightGoList.baseCabinName,
        price: this.fightGoList.price,
        hasChildren:this.children,
         hasBaby:this.hasBaby,
      };
      //   返程信息
      let BackSearchWhere = {
        CabinMessage:this.fightBackList,
        active: this.active4,
        DepDate: e,
        DstAirport: this.GoSearchWhere.OrgAirport,
        FlightNo: this.fightBackNum.flightNo,
        OrgAirport: this.GoSearchWhere.DstAirport,
        channelType: this.fightBackNum.channelType,
        // index: index,
        cabin: this.fightBackList.cabin,
        baseCabin: this.fightBackList.baseCabin,
        baseCabinName: this.fightBackList.baseCabinName,
        price: this.fightBackList.price,
      };
      this.$router.push({
        name: "flightschedule",
        params: {
          GoSearchWhere: GoSearchWhere,
          BackSearchWhere: BackSearchWhere,
          //   flightMes: item,
          type: "return",
        },
      });
    },
    // // 往返信息
    getgetFlightInfoListBack(channelType, FlightNo) {
      this.showLoading();
      this.$axios
        .getgetFlightInfoListBack({
          // 航班号
          FlightNo: FlightNo,
          channelType: channelType,
          // 去程信息
          GoSearchWhere: {
            DepDate: this.GoSearchWhere.DepDate,
            OrgAirport: this.GoSearchWhere.OrgAirport,
            DstAirport: this.GoSearchWhere.DstAirport,
            // DepDate: "2022-09-23",
            // OrgAirport: "上海",
            // DstAirport: "北京"
          },
          // 返程信息
          BackSearchWhere: {
            DepDate: this.GoSearchWhere.ArrivedDate,
            OrgAirport: this.GoSearchWhere.DstAirport,
            DstAirport: this.GoSearchWhere.OrgAirport,
            // DepDate: "2022-10-30",
            // OrgAirport: "北京",
            // DstAirport: "上海"
          },
          hasChildren: this.GoSearchWhere.hasChildren,
          // hasChildren: false
        })
        .then((res) => {
          this.closeLoading();
          console.log(res);
          if (res.code == 200) {
            this.BackSearchList = res.data;
          } else {
            this.$message({
              showClose: true,
              message: "航班信息发生变化,为您重新加载",
              type: "warning",
            });
            this.Searchagain();
          }
        });
    },
    // 当前去程信息点击事件
    GoSearchClick(index, row) {
      this.active = index;
      console.log(row);
      this.getgetFlightInfoListBack(row.channelType, row.flightNo);
      // 去程所有舱位
      this.goshippingspace = row.listCabinInfo;
      // this.fightGoList = row.listCabinInfo[0]
      this.fightGoNum = row;
      this.fightBackList.price = null;
    },
    BackSearchClick(index, row) {
      this.active1 = index;
      console.log(row);
      // 返程所有舱位
      this.Backshippingspace = row.listCabinInfo;
      // this.fightBackList = row.listCabinInfo[0]
      this.fightBackNum = row;
    },
    // 查询去程信息
    postflightInfoList() {
      this.showLoading();
      console.log(this.GoSearchWhere.DepDate);
      let GoSearchWhere = {
        DepDate: this.GoSearchWhere.DepDate,
        OrgAirport: this.GoSearchWhere.OrgAirport,
        DstAirport: this.GoSearchWhere.DstAirport,
      };
      let BackSearchWhere = {
        DepDate: this.GoSearchWhere.ArrivedDate,
        OrgAirport: this.GoSearchWhere.DstAirport,
        DstAirport: this.GoSearchWhere.OrgAirport,
      };
      console.log(GoSearchWhere, BackSearchWhere);
      this.$axios
        .getflightSearch({
          // 去程信息
          GoSearchWhere: GoSearchWhere,
          // 返程信息
          BackSearchWhere: BackSearchWhere,
          hasChildren: this.children,
          hasBaby: this.hasBaby,
          TripType: "roundTrip",
        })
        .then((res) => {
          this.closeLoading();
          console.log(res);
          if (res.code == "00000") {
            this.GoSearchWhereList = res.data[0].flightDTOS;
            this.BackSearchList = res.data[0].backFlightDTOS
            if (this.GoSearchWhereList.length != 0&& this.BackSearchList.length!=0) {
              this.resource ='departtime';
              this.pricedata(this.GoSearchWhereList);
              this.pricedata(this.BackSearchList);
              console.log(this.GoSearchWhereList);
              console.log(this.BackSearchList);
              
            }
            if (res.data.length == 0) {
              this.$message({
                showClose: true,
                message: "当前时间暂无航班信息",
                type: "warning",
              });
            }
          }
        });
    },
    // 价格时间排序(去程)
    pricedata(row) {
      // debugger
      if (this.filteractive == "departtime") {
        row.forEach((item) => {
          item.listCabinInfo.sort(function (a, b) {
            return a.price > b.price ? 1 : -1;
          });
        });
        row.sort(function (a, b) {
          return a.listCabinInfo[0].price > b.listCabinInfo[0].price ? 1 : -1;
        });
        return row;
      }
      // 时间排序
      if (this.filteractive == "runtime") {
        row.sort(function (a, b) {
          return a.depDate > b.depDate ? 1 : -1;
        });
        return row;
      }
    },
    // 价格时间排序(返程)
    pricedataasas(row) {
      // debugger
      if (this.filteractiveasas == "departtime") {
        row.forEach((item) => {
          item.listCabinInfo.sort(function (a, b) {
            return a.price > b.price ? 1 : -1;
          });
        });
        row.sort(function (a, b) {
          return a.listCabinInfo[0].price > b.listCabinInfo[0].price ? 1 : -1;
        });
        return row;
      }
      // 时间排序
      if (this.filteractiveasas == "runtime") {
        row.sort(function (a, b) {
          return a.depDate > b.depDate ? 1 : -1;
        });
        return row;
      }
    },
    // filteractiveasas
    // 时间排序(去程)
    filtrates(tab) {
      console.log(tab);
      let list = this.GoSearchWhereList;
      if (this.filteractive == tab._props.name) {
      } else {
        (this.filteractive = tab._props.name),
          (list = this.pricedata(list)),
          (this.GoSearchWhereList = list);
      }
    },
    // 时间排序(返程)
    filtratesasas(tab) {
      // debugger
      console.log(tab);
      let list = this.BackSearchList;
      if (this.filteractiveasas == tab._props.name) {
      } else {
        (this.filteractiveasas = tab._props.name),
          (list = this.pricedataasas(list)),
          (this.BackSearchList = list);
      }
    },
    // 重新搜索按钮
    Searchagain() {
      this.postflightInfoList();
      // <span>去程机建：{{fightGoNum.airportTax}}</span><br />
      //             <span>去程燃油：{{fightGoNum.fuelTax}}</span><br />
      //             <span>返程票价：{{fightBackList.price}}</span><br />
      // this.goshippingspace = []
      // this.Backshippingspace = []
      // this.GoSearchWhereList = []
      // this.BackSearchList = []
      // this.fightBackList = {}
      // this.fightGoList = {}
      // this.fightGoList.price=0
      //  this.fightBackList.price=0
      // if (this.GoSearchWhere.ArrivedDate != '' && this.GoSearchWhere.DepDate != '' && this.GoSearchWhere
      //     .DstAirport != '' && this.GoSearchWhere.OrgAirport != '') {
      //     this.postflightInfoList()
      // } else {
      //     this.$message({
      //         message: '请选择完整信息再进行查新',
      //         type: 'warning'
      //     });
      // }
      this.postflightInfoList();
    },
  
    //跳出
    closeLoading() {
      this.tableLoading.close();
    },
    //进入
    showLoading() {
      this.tableLoading = this.$loading({
        text: "拼命加载数据中", //显示在加载图标下方的加载文案
        spinner: "el-icon-loading", //自定义加载图标类名
        background: "rgba(0, 0, 0, 0.4)", //遮罩层颜色
        target: document.querySelector("#table"), //loadin覆盖的dom元素节点
      });
    },

    flightCityList() {
      this.$axios.getQueryAllCRMByIsUsed().then((res) => {
        console.log(res);
        if (res.code == "00000") {
          this.restaurants = res.data;
          // return this.restaurants
        }
      });
    },
  },
  mounted() {
    this.flightCityList();

    console.log( this.$route.params.BackSearchWhere)
    this.GoSearchWhere.ArrivedDate =
      this.$route.params.BackSearchWhere.ArrivedDate;
    this.GoSearchWhere.DepDate = this.$route.params.BackSearchWhere.DepDate;
    this.GoSearchWhere.DstAirport = this.$route.params.BackSearchWhere.DstAirport;
    this.GoSearchWhere.OrgAirport = this.$route.params.BackSearchWhere.OrgAirport;
    this.children = this.$route.params.BackSearchWhere.children;
    this.hasBaby = this.$route.params.BackSearchWhere.hasBaby;
    console.log(this.GoSearchWhere);

    this.postflightInfoList();
  },
};
</script>
<style scoped>
.Backforth {
  margin: 20px;
}

.GoSearch {
  display: flex;
  margin: 0 0 20px 0;
  border-bottom: 1px solid #696969;
  margin-top: 20px;
}

.GoSearch1 {
  display: flex;
  margin: 0 0 20px 0;
  border-bottom: 1px solid #696969;
  background-color: #e8f7ff;
  /* margin-top: 20px; */
}

.boxa {
  height: 300px;
  overflow-y: scroll;
}

.boxcc {
  height: 100px;
  overflow-y: scroll;
}

.boxads {
  height: 300px;
  overflow-y: scroll;
  width: 50%;
}

::-webkit-scrollbar {
  /*隐藏滚轮*/
  display: none;
}
</style>